//
//  NSSet+Safe.m
//  niuguwang
//
//  Created by BrightLi on 2021/6/15.
//  Copyright © 2021年 taojinzhe. All rights reserved.
//

#import "NSSet+Safe.h"
#import "YMSafeUtil.h"

@implementation NSSet(Safe)

+ (void) safe_fixed
{
    static dispatch_once_t onceToken;
    //__NSPlaceholderSet initWithObjects:count:

    dispatch_once(&onceToken, ^{
        [YMSafeUtil swizzleInstance:NSClassFromString(@"__NSPlaceholderSet")
                    sel1:@selector(initWithObjects:count:)
                    sel2:@selector(safe_initWithObjects:count:)];
    });
}

-(id) safe_initWithObjects:(const id [])objects
                  count:(NSUInteger)cnt
{
    id object=nil;
    @try {
        object = [self safe_initWithObjects:objects count:cnt];
    }
    @catch (NSException *exception) {
        [YMSafeUtil stackLog:exception start:5];
    }
    @finally {
        return object;
    }
}

@end
